/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package bean;

import java.sql.*;
import oracle.jdbc.pool.OracleDataSource;

public class DataBaseConnection {

    private String username ;
    private String passwd ;
    private String nama ;
    
    private String username3 ;
    private String passwd3 ;
    private String nama3 ;
    
    private String nim ;
    private String namapanggil ;
    private String namapanjang ;
    private String angkatan ;
    private String fakultas ;
    private String prodi ;
    private String ttl ;
    private String alamat ;
    private String agama ;
    private String sma ;
    private String namaortu ;
    private String alamatortu ;
    
    private String namapanjang2;
    private String nim2;
    private String prodi2;
    private String semester;
    private String jumlahsks;
    private String ipsemester;
    private String jatahambil;
    
    private String nomor;
    private String matkul;
    private String kode;
    private String sks;
    private String nilai;
    private String remidi;
    private String nilairemidi; 
    
    private String jumlah;
    
    private String no;
    private String matkul2;
    private String kelas;
    private String hari1;
    private String hari2;
    private String hari3;
    private String hari4;
    private String hari5;
    
    private static Connection conn;

// Sesuaikan properti jdbcURL dengan basis data anda
    private String jdbcUrl = "jdbc:oracle:thin:@localhost:1521:xe";
    String userid = "system";
    String password = "kinarreka";
//    private String jdbcUrl = "jdbc:oracle:thin:@172.23.9.185:1521:orcl";
//    String userid = "MHS105314058";
//    String password = "MHS105314058";

    /** Creates a new instance of UserConnection */
    
//    public DataBaseConnection(){
//        try{
//            OracleDataSource ds;
//            ds = new OracleDataSource();
//            ds.setURL(jdbcUrl);
//            conn = ds.getConnection(userid, password);
//            System.out.println("Koneksi Berhasil");
////            return conn;
//        }catch(SQLException ex){
//            System.out.println("Koneksi Gagal");
////            return null;
//        }
//    }
    
    
    
//    public DataBaseConnection() {
//        try {
//            OracleDataSource ds;
//            ds = new OracleDataSource();
//            ds.setURL(jdbcUrl);
//            conn = ds.getConnection(userid, password);
//            System.out.println("Koneksi berhasil");
//        } catch (SQLException ex) {
//            System.out.println("Masih belum koneksi");
//        }
//    }
    public DataBaseConnection(){

    }

    public DataBaseConnection(String username, String passwd, String nama){
        this.username = username;
        this.passwd = passwd;
        this.nama = nama;
    }

    public boolean isConnected(){
        if (conn!=null) {
            return true;
        }
        else {
            return false;
        }
    }
    public boolean getClosed(){
        if(isConnected()){
            try {
                conn.close();
                conn=null;
            } catch (SQLException ex) {
            }
            return true;
        } else {
            return false;
        }
    }

    public String getJdbcUrl() {
        return jdbcUrl;
    }

    public void setJdbcUrl(String jdbcUrl) {
        this.jdbcUrl = jdbcUrl;
    }   

    public Connection getConnection() {
        try{
            OracleDataSource ds;
            ds = new OracleDataSource();
            ds.setURL(jdbcUrl);
            conn = ds.getConnection(userid, password);
            System.out.println("Koneksi Berhasil");
            return conn;
        }catch(SQLException ex){
            System.out.println("Koneksi Gagal");
            return null;
        }
    }

    public void setConn(Connection connection) {
        DataBaseConnection.conn = connection;
    }
    
    public static void main(String[] args) {
        DataBaseConnection test = new DataBaseConnection();
        test.getConnection();
//        test.close();
    }

//    public static void main(String args[]){
//        DataBaseConnection conn = new DataBaseConnection();
//
//        try{
//            String query="select * from loginDB";
//            Statement statement = conn.getConnection().createStatement();
//            ResultSet result = statement.executeQuery(query);
//
//            while (result.next()){
//                System.out.println("Username : "+result.getString("username"));
//                System.out.println("Password  : "+result.getString("passwd"));
//                System.out.println("Nama : "+result.getString("nama"));
//            }
//            statement.close();
//        } catch(Exception ex){
//            System.out.println("message: "+ex.getMessage());
//        }
//
//    }


    /**
     * @return the nama
     */
    public String getUsername() {
        return username;
    }

    /**
     * @param usernama the nama to set
     */
    public void setUsername(String username) {
        this.username = username;
    }

    /**
     * @return the paswd
     */
    public String getPasswd() {
        return passwd;
    }

    /**
     * @param passwd the paswd to set
     */
    public void setPasswd(String passwd) {
        this.passwd = passwd;
    }
    
    public String getNama() {
        return nama;
    }
    
    public void setNama(String nama) {
        this.nama = nama;
    }

    /**
     * @return the nim
     */
    public String getNim() {
        return nim;
    }

    /**
     * @param nim the nim to set
     */
    public void setNim(String nim) {
        this.nim = nim;
    }

    /**
     * @return the namapanjang
     */
    public String getNamapanjang() {
        return namapanjang;
    }

    /**
     * @param namapanjang the namapanjang to set
     */
    public void setNamapanjang(String namapanjang) {
        this.namapanjang = namapanjang;
    }

    /**
     * @return the angkatan
     */
    public String getAngkatan() {
        return angkatan;
    }

    /**
     * @param angkatan the angkatan to set
     */
    public void setAngkatan(String angkatan) {
        this.angkatan = angkatan;
    }

    /**
     * @return the fakultas
     */
    public String getFakultas() {
        return fakultas;
    }

    /**
     * @param fakultas the fakultas to set
     */
    public void setFakultas(String fakultas) {
        this.fakultas = fakultas;
    }

    /**
     * @return the prodi
     */
    public String getProdi() {
        return prodi;
    }

    /**
     * @param prodi the prodi to set
     */
    public void setProdi(String prodi) {
        this.prodi = prodi;
    }

    /**
     * @return the ttl
     */
    public String getTtl() {
        return ttl;
    }

    /**
     * @param ttl the ttl to set
     */
    public void setTtl(String ttl) {
        this.ttl = ttl;
    }

    /**
     * @return the alamat
     */
    public String getAlamat() {
        return alamat;
    }

    /**
     * @param alamat the alamat to set
     */
    public void setAlamat(String alamat) {
        this.alamat = alamat;
    }

    /**
     * @return the agama
     */
    public String getAgama() {
        return agama;
    }

    /**
     * @param agama the agama to set
     */
    public void setAgama(String agama) {
        this.agama = agama;
    }

    /**
     * @return the sma
     */
    public String getSma() {
        return sma;
    }

    /**
     * @param sma the sma to set
     */
    public void setSma(String sma) {
        this.sma = sma;
    }

    /**
     * @return the namaortu
     */
    public String getNamaortu() {
        return namaortu;
    }

    /**
     * @param namaortu the namaortu to set
     */
    public void setNamaortu(String namaortu) {
        this.namaortu = namaortu;
    }

    /**
     * @return the alamatortu
     */
    public String getAlamatortu() {
        return alamatortu;
    }

    /**
     * @param alamatortu the alamatortu to set
     */
    public void setAlamatortu(String alamatortu) {
        this.alamatortu = alamatortu;
    }

    /**
     * @return the namapanjang2
     */
    public String getNamapanjang2() {
        return namapanjang2;
    }

    /**
     * @param namapanjang2 the namapanjang2 to set
     */
    public void setNamapanjang2(String namapanjang2) {
        this.namapanjang2 = namapanjang2;
    }

    /**
     * @return the nim2
     */
    public String getNim2() {
        return nim2;
    }

    /**
     * @param nim2 the nim2 to set
     */
    public void setNim2(String nim2) {
        this.nim2 = nim2;
    }

    /**
     * @return the prodi2
     */
    public String getProdi2() {
        return prodi2;
    }

    /**
     * @param prodi2 the prodi2 to set
     */
    public void setProdi2(String prodi2) {
        this.prodi2 = prodi2;
    }

    /**
     * @return the semester
     */
    public String getSemester() {
        return semester;
    }

    /**
     * @param semester the semester to set
     */
    public void setSemester(String semester) {
        this.semester = semester;
    }

    /**
     * @return the nomor
     */
    public String getNomor() {
        return nomor;
    }

    /**
     * @param nomor the nomor to set
     */
    public void setNomor(String nomor) {
        this.nomor = nomor;
    }

    /**
     * @return the matkul
     */
    public String getMatkul() {
        return matkul;
    }

    /**
     * @param matkul the matkul to set
     */
    public void setMatkul(String matkul) {
        this.matkul = matkul;
    }

    /**
     * @return the kode
     */
    public String getKode() {
        return kode;
    }

    /**
     * @param kode the kode to set
     */
    public void setKode(String kode) {
        this.kode = kode;
    }

    /**
     * @return the sks
     */
    public String getSks() {
        return sks;
    }

    /**
     * @param sks the sks to set
     */
    public void setSks(String sks) {
        this.sks = sks;
    }

    /**
     * @return the nilai
     */
    public String getNilai() {
        return nilai;
    }

    /**
     * @param nilai the nilai to set
     */
    public void setNilai(String nilai) {
        this.nilai = nilai;
    }

    /**
     * @return the remidi
     */
    public String getRemidi() {
        return remidi;
    }

    /**
     * @param remidi the remidi to set
     */
    public void setRemidi(String remidi) {
        this.remidi = remidi;
    }

    /**
     * @return the nilairemidi
     */
    public String getNilairemidi() {
        return nilairemidi;
    }

    /**
     * @param nilairemidi the nilairemidi to set
     */
    public void setNilairemidi(String nilairemidi) {
        this.nilairemidi = nilairemidi;
    }

    /**
     * @return the jumlahsks
     */
    public String getJumlahsks() {
        return jumlahsks;
    }

    /**
     * @param jumlahsks the jumlahsks to set
     */
    public void setJumlahsks(String jumlahsks) {
        this.jumlahsks = jumlahsks;
    }

    /**
     * @return the ipsemester
     */
    public String getIpsemester() {
        return ipsemester;
    }

    /**
     * @param ipsemester the ipsemester to set
     */
    public void setIpsemester(String ipsemester) {
        this.ipsemester = ipsemester;
    }

    /**
     * @return the jatahambil
     */
    public String getJatahambil() {
        return jatahambil;
    }

    /**
     * @param jatahambil the jatahambil to set
     */
    public void setJatahambil(String jatahambil) {
        this.jatahambil = jatahambil;
    }

    /**
     * @return the username3
     */
    public String getUsername3() {
        return username3;
    }

    /**
     * @param username3 the username3 to set
     */
    public void setUsername3(String username3) {
        this.username3 = username3;
    }

    /**
     * @return the passwd3
     */
    public String getPasswd3() {
        return passwd3;
    }

    /**
     * @param passwd3 the passwd3 to set
     */
    public void setPasswd3(String passwd3) {
        this.passwd3 = passwd3;
    }

    /**
     * @return the nama3
     */
    public String getNama3() {
        return nama3;
    }

    /**
     * @param nama3 the nama3 to set
     */
    public void setNama3(String nama3) {
        this.nama3 = nama3;
    }

    /**
     * @return the namapanggil
     */
    public String getNamapanggil() {
        return namapanggil;
    }

    /**
     * @param namapanggil the namapanggil to set
     */
    public void setNamapanggil(String namapanggil) {
        this.namapanggil = namapanggil;
    }

    /**
     * @return the jumlah
     */
    public String getJumlah() {
        return jumlah;
    }

    /**
     * @param jumlah the jumlah to set
     */
    public void setJumlah(String jumlah) {
        this.jumlah = jumlah;
    }

    /**
     * @return the no
     */
    public String getNo() {
        return no;
    }

    /**
     * @param no the no to set
     */
    public void setNo(String no) {
        this.no = no;
    }

    /**
     * @return the matkul2
     */
    public String getMatkul2() {
        return matkul2;
    }

    /**
     * @param matkul2 the matkul2 to set
     */
    public void setMatkul2(String matkul2) {
        this.matkul2 = matkul2;
    }

    /**
     * @return the kelas
     */
    public String getKelas() {
        return kelas;
    }

    /**
     * @param kelas the kelas to set
     */
    public void setKelas(String kelas) {
        this.kelas = kelas;
    }

    /**
     * @return the hari1
     */
    public String getHari1() {
        return hari1;
    }

    /**
     * @param hari1 the hari1 to set
     */
    public void setHari1(String hari1) {
        this.hari1 = hari1;
    }

    /**
     * @return the hari2
     */
    public String getHari2() {
        return hari2;
    }

    /**
     * @param hari2 the hari2 to set
     */
    public void setHari2(String hari2) {
        this.hari2 = hari2;
    }

    /**
     * @return the hari3
     */
    public String getHari3() {
        return hari3;
    }

    /**
     * @param hari3 the hari3 to set
     */
    public void setHari3(String hari3) {
        this.hari3 = hari3;
    }

    /**
     * @return the hari4
     */
    public String getHari4() {
        return hari4;
    }

    /**
     * @param hari4 the hari4 to set
     */
    public void setHari4(String hari4) {
        this.hari4 = hari4;
    }

    /**
     * @return the hari5
     */
    public String getHari5() {
        return hari5;
    }

    /**
     * @param hari5 the hari5 to set
     */
    public void setHari5(String hari5) {
        this.hari5 = hari5;
    }


}



